//
//  OKBottomView.m
//  fast
//
//  Created by answer on 16/5/21.
//  Copyright © 2016年 answer. All rights reserved.
//

#import "OKBottomView.h"
#import "OKButton.h"
#import "OKSickChooseBtn.h"
#define kScreenWidth [UIScreen mainScreen].bounds.size.width

@implementation OKBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self setupUI];
}

- (void)setupUI {
    
    CGFloat btnWidth = kScreenWidth/3.0;
    CGFloat btnHeight = self.bounds.size.height/2;
    
    for (NSInteger i = 0; i < 6; i ++) {
        
        CGFloat btnX = i%3*(btnWidth+1);
        CGFloat btnY = 1+i/3*(btnHeight+1);
        
        OKSickChooseBtn *button = [[OKSickChooseBtn alloc] init];
        
        NSString *imageName = [NSString stringWithFormat:@"%zd",i+1];
        UIImage *image = [UIImage imageNamed:imageName];
        
        NSArray *sickArray = @[@"肿瘤", @"心血管", @"神经科", @"血液科", @"骨科", @"公益活动"];
        button.backgroundColor = [UIColor whiteColor];
        
        button.nameLabel.text = sickArray[i];
        
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
       // [button setImage:image forState:UIControlStateNormal];
        button.iconView.image = image;
        button.ci1_id = i + 1;
        
        button.frame = CGRectMake(btnX, btnY, btnWidth, btnHeight);
        // 添加点击事件
        [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
}

- (void)btnClick:(OKButton *)btn {
    if ([self.delegate respondsToSelector:@selector(btnClickCallBackWithButtonindex:)]) {
        [self.delegate btnClickCallBackWithButtonindex:btn.ci1_id];
    }
    
}


@end
